package de.yvert.jingle.impl.openexr;

import java.io.IOException;

public class Box2iAttribute extends Attribute
{

public static final String TYPE = "box2i";
public static final int SIZE = 16;

private final int x0, y0, x1, y1;

public Box2iAttribute(String name, int x0, int y0, int x1, int y1)
{
	super(name);
	this.x0 = x0;
	this.y0 = y0;
	this.x1 = x1;
	this.y1 = y1;
}

public int getWidth()
{ return x1-x0+1; }

public int getHeight()
{ return y1-y0+1; }

@Override
public String toString()
{ return TYPE+" \""+getName()+"\" = "+x0+" "+y0+" -> "+x1+" "+y1; }

public int getTop()
{ return y0; }

@Override
public void write(ExrOutputStream out) throws IOException
{
	out.writeString(getName());
	out.writeString(TYPE);
	out.writeInt(SIZE);
	out.writeInt(x0);
	out.writeInt(y0);
	out.writeInt(x1);
	out.writeInt(y1);
}

}
